﻿function ClientAddDocumentType() {
    Url = Portal.OfficeMan.DocumentType.GetAddUrl().value;
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, '_self');
    //ClientReading();
}

function ClientSaveAddDocumentType() {
    DocumentTypeCode = document.getElementById("txtDocumentTypeCode").value;
    DocumentTypeName = document.getElementById("txtDocumentTypeName").value;

    RetValue = Portal.OfficeMan.AddDocumentType.ServerSideAddDocumentType(DocumentTypeCode, DocumentTypeName).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    document.getElementById("txtDocumentTypeCode").value = "";
    document.getElementById("txtDocumentTypeName").value = "";
    document.getElementById("txtDocumentTypeName").focus();
    
    //window.close();
}

function ClientUpdateDocumentType(DocumentTypeId) {
    Url = Portal.OfficeMan.DocumentType.GetUpdateUrl(DocumentTypeId).value;
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    //ClientReading();
    window.open(Url, '_self');
}

function ClientDeleteDocumentType(DocumentTypeId)
{
    Msg=Portal.OfficeMan.DocumentType.GetConfirmDeleteMsg().value;
    if(confirm(Msg)==false)return;
    RetValue = Portal.OfficeMan.DocumentType.ServerSideDeleteDocumentType(DocumentTypeId).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    ClientReading();
}



function ShowClientUpdateUrlForm(DocumentTypeId)
{
    Url = Portal.OfficeMan.DocumentType.GetUpdateUrl(DocumentTypeId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    win.open(Url, '_self');
}


function ClientSaveUpdateDocumentType(DocumentTypeId)
{
    DocumentTypeCode = document.getElementById("txtDocumentTypeCode").value;
    DocumentTypeName = document.getElementById("txtDocumentTypeName").value;

    RetValue = Portal.OfficeMan.UpdateDocumentType.ServerSideUpdateDocumentType(DocumentTypeId,DocumentTypeCode, DocumentTypeName).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    //window.close();
    window.open("Default.aspx?WebPartId=DocumentType", "_self");
}

function ClientReading() {
   document.getElementById("divProcessing").innerHTML = Portal.OfficeMan.DocumentType.GetProcessingText().value;
   setTimeout("RealClientReading()",10);
}

function RealClientReading() {
    rValue = Portal.OfficeMan.DocumentType.GetDocumentType().value;
    document.getElementById("divDocumentTypeContent").innerHTML = rValue;
    document.getElementById("divProcessing").innerHTML = "";
}
